from flask import Flask
from .scheduler import start_scheduler

def create_app():
    """应用工厂函数"""
    app = Flask(__name__)
    
    # 注册蓝图
    from .main import main_bp
    from .evaluation import evaluation_bp
    from .fund_config import fund_config_bp
    from .api import api_bp
    from .latest_valuation import latest_valuation_bp
    from .fund_chart import fund_chart_bp
    from .market_sentiment import market_sentiment_bp
    
    app.register_blueprint(main_bp)
    app.register_blueprint(evaluation_bp)
    app.register_blueprint(fund_config_bp)
    app.register_blueprint(api_bp)
    app.register_blueprint(latest_valuation_bp)
    app.register_blueprint(fund_chart_bp)
    app.register_blueprint(market_sentiment_bp)
    
    # 启动调度器
    start_scheduler()
    
    return app